using System;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;

namespace Edge.Common.Web.DataUtils
{
    /// <summary>
    /// Fasade
    /// </summary>
    public delegate object GetPropertyValue(object src);
    public delegate void SetPropertyValue(object obj, object value);

    public interface IPropertyValueGetter
    {
        object Get(object source);
    }

    public interface IPropertyValueSetter
    {
        void Set(object obj, object value);
    }

    /// <summary>
    /// Products data manipualte helper
    /// </summary>
    public class Manipulation
    {
        #region constructor

        protected Manipulation()
        {
        }

        #endregion

        #region Getters

        protected class DelegateValueGetter : IPropertyValueGetter
        {
            GetPropertyValue _delegate;

            public DelegateValueGetter(GetPropertyValue theDelegate)
            {
                _delegate = theDelegate;
            }

            public object Get(object source)
            {
                return _delegate(source);
            }

        }

        protected class DynamicValueGetter : IPropertyValueGetter
        {
            string _name;

            public DynamicValueGetter(string name)
            {
                _name = name;
            }

            public object Get(object source)
            {
                return DataBinder.Eval(source, _name);
            }

        }

        protected class DelegateValueSetter : IPropertyValueSetter
        {
            SetPropertyValue _delegate;

            public DelegateValueSetter(SetPropertyValue theDelegate)
            {
                _delegate = theDelegate;
            }

            public void Set(object obj, object value)
            {
                _delegate(obj, value);
            }

        }

        protected class DynamicValueSetter : IPropertyValueSetter
        {
            string _name;

            public DynamicValueSetter(string name)
            {
                _name = name;
            }

            public void Set(object obj, object value)
            {
                // TODO
                throw new NotImplementedException();
            }

        }

        #endregion

        

    }
}
